package org.alex.mqtt.common.netty;

import io.netty.channel.Channel;
import io.netty.util.AttributeKey;
import org.alex.mqtt.common.MQTTConnection;

/**
 * mqtt netty工具
 * @author : alex
 */
public class MqttNettyUtils {
    private static final String CONNECTION = "connection";
    private static final AttributeKey<Object> ATTR_KEY_CONNECTION = AttributeKey.valueOf(CONNECTION);
    public static MQTTConnection mqttConnection(Channel channel){
        return (MQTTConnection) channel.attr(ATTR_KEY_CONNECTION).get();
    }
}
